<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Linux 网络性能优化指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .code-block {
            background: #1e293b;
            color: #e2e8f0;
            border-radius: 12px;
            padding: 1.5rem;
            overflow-x: auto;
            position: relative;
        }
        .code-block::before {
            content: 'BASH';
            position: absolute;
            top: 0.5rem;
            right: 1rem;
            font-size: 0.75rem;
            color: #64748b;
            font-weight: 600;
        }
        .section-number {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-weight: 700;
            font-size: 3rem;
            line-height: 1;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        .highlight-box {
            background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
            border-radius: 12px;
            padding: 1.5rem;
            margin: 1rem 0;
            position: relative;
            overflow: hidden;
        }
        .highlight-box::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
            animation: shimmer 3s infinite;
        }
        @keyframes shimmer {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-family: 'Noto Serif SC', serif;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center">
            <h1 class="text-5xl md:text-6xl font-bold mb-6 tracking-tight">
                <i class="fas fa-network-wired mr-4"></i>Linux 网络性能优化指南
            </h1>
            <p class="text-xl md:text-2xl opacity-90 max-w-3xl mx-auto leading-relaxed">
                深入探索 Linux 系统网络参数配置，提升吞吐量，降低延迟，打造高性能网络环境
            </p>
            <div class="mt-10 flex justify-center space-x-6">
                <div class="bg-white bg-opacity-20 rounded-lg px-6 py-3 backdrop-blur-sm">
                    <i class="fas fa-rocket text-2xl"></i>
                    <p class="text-sm mt-1">高吞吐量</p>
                </div>
                <div class="bg-white bg-opacity-20 rounded-lg px-6 py-3 backdrop-blur-sm">
                    <i class="fas fa-tachometer-alt text-2xl"></i>
                    <p class="text-sm mt-1">低延迟</p>
                </div>
                <div class="bg-white bg-opacity-20 rounded-lg px-6 py-3 backdrop-blur-sm">
                    <i class="fas fa-shield-alt text-2xl"></i>
                    <p class="text-sm mt-1">稳定可靠</p>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-6 py-12">
        <!-- Introduction -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-12 card-hover">
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">在</span>Linux 环境下，配置和优化网络参数以提高网络吞吐量和降低延迟涉及多个方面。本指南将带您深入了解各种优化技巧，从 TCP 参数调整到硬件配置，全方位提升您的网络性能。
            </p>
        </div>

        <!-- Network Optimization Diagram -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-12">
            <h2 class="text-3xl font-bold mb-6 text-center text-gray-800">
                <i class="fas fa-sitemap mr-3 text-purple-600"></i>网络优化架构图
            </h2>
            <div class="mermaid">
                graph TD
                    A[Linux 网络优化] --> B[TCP 参数调整]
                    A --> C[网络缓冲区优化]
                    A --> D[网络接口配置]
                    A --> E[网络堆栈优化]
                    A --> F[监控与调试]
                    A --> G[硬件优化]
                    
                    B --> B1[TCP 窗口大小]
                    B --> B2[TCP 保活设置]
                    
                    C --> C1[默认缓冲区]
                    C --> C2[最大缓冲区]
                    
                    D --> D1[ethtool 配置]
                    D --> D2[中断负载均衡]
                    
                    E --> E1[端口范围]
                    E --> E2[拥塞控制算法]
                    
                    F --> F1[监控工具]
                    F --> F2[性能分析]
                    
                    G --> G1[硬件选择]
                    G --> G2[故障检查]
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:3px,color:#fff
                    style B fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                    style C fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                    style D fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                    style E fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                    style F fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                    style G fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </div>

        <!-- Section 1: TCP Parameters -->
        <div class="grid md:grid-cols-12 gap-8 mb-12">
            <div class="md:col-span-2">
                <div class="sticky top-8">
                    <span class="section-number">1</span>
                </div>
            </div>
            <div class="md:col-span-10">
                <div class="bg-white rounded-2xl shadow-xl p-8 card-hover">
                    <h2 class="text-3xl font-bold mb-6 text-gray-800">
                        <i class="fas fa-sliders-h mr-3 text-purple-600"></i>调整 TCP 参数
                    </h2>
                    
                    <!-- TCP Window Size -->
                    <div class="mb-8">
                        <h3 class="text-xl font-semibold mb-4 text-gray-700">
                            <i class="fas fa-window-maximize mr-2 text-purple-500"></i>TCP 窗口大小
                        </h3>
                        <p class="text-gray-600 mb-4 leading-relaxed">
                            通过调整发送和接收缓冲区的大小，可以显著提高大流量数据的吞吐量。以下参数控制着 TCP 连接的缓冲区配置：
                        </p>
                        <div class="grid md:grid-cols-2 gap-4 mb-4">
                            <div class="bg-purple-50 rounded-lg p-4">
                                <code class="text-purple-700 font-mono font-semibold">net.core.wmem_max</code>
                                <p class="text-sm text-gray-600 mt-1">发送缓冲区最大值</p>
                            </div>
                            <div class="bg-purple-50 rounded-lg p-4">
                                <code class="text-purple-700 font-mono font-semibold">net.core.rmem_max</code>
                                <p class="text-sm text-gray-600 mt-1">接收缓冲区最大值</p>
                            </div>
                        </div>
                        <div class="code-block">
                            <pre><code>sysctl -w net.core.wmem_max=16777216
sysctl -w net.core.rmem_max=16777216
sysctl -w net.ipv4.tcp_wmem="4096 87380 16777216"
sysctl -w net.ipv4.tcp_rmem="4096 87380 16777216"</code></pre>
                        </div>
                    </div>

                    <!-- TCP Keepalive -->
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-700">
                            <i class="fas fa-heartbeat mr-2 text-purple-500"></i>TCP 保活设置
                        </h3>
                        <p class="text-gray-600 mb-4 leading-relaxed">
                            调整 TCP 保活探测参数，确保长时间连接的稳定性，避免因超时而断开：
                        </p>
                        <div class="code-block">
                            <pre><code>sysctl -w net.ipv4.tcp_keepalive_time=600
sysctl -w net.ipv4.tcp_keepalive_intvl=30
sysctl -w net.ipv4.tcp_keepalive_probes=5</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Section 2: Network Buffers -->
        <div class="grid md:grid-cols-12 gap-8 mb-12">
            <div class="md:col-span-2">
                <div class="sticky top-8">
                    <span class="section-number">2</span>
                </div>
            </div>
            <div class="md:col-span-10">
                <div class="bg-white rounded-2xl shadow-xl p-8 card-hover">
                    <h2 class="text-3xl font-bold mb-6 text-gray-800">
                        <i class="fas fa-database mr-3 text-purple-600"></i>优化网络缓冲区
                    </h2>
                    <p class="text-gray-600 mb-4 leading-relaxed">
                        合理配置网络缓冲区大小，可以有效提升数据传输效率：
                    </p>
                    <div class="highlight-box">
                        <h3 class="text-xl font-semibold mb-3 text-gray-800">
                            <i class="fas fa-cog mr-2"></i>调整默认缓冲区
                        </h3>
                        <p class="text-gray-700 mb-4">设置系统默认的接收和发送缓冲区大小，确保常规连接获得足够的缓冲空间。</p>
                        <div class="code-block">
                            <pre><code>sysctl -w net.core.rmem_default=262144
sysctl -w net.core.wmem_default=262144</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Section 3: Network Interface -->
        <div class="grid md:grid-cols-12 gap-8 mb-12">
            <div class="md:col-span-2">
                <div class="sticky top-8">
                    <span class="section-number">3</span>
                </div>
            </div>
            <div class="md:col-span-10">
                <div class="bg-white rounded-2xl shadow-xl p-8 card-hover">
                    <h2 class="text-3xl font-bold mb-6 text-gray-800">
                        <i class="fas fa-ethernet mr-3 text-purple-600"></i>配置网络接口
                    </h2>
                    
                    <!-- ethtool Configuration -->
                    <div class="mb-8">
                        <h3 class="text-xl font-semibold mb-4 text-gray-700">
                            <i class="fas fa-tools mr-2 text-purple-500"></i>调整网络接口参数
                        </h3>
                        <p class="text-gray-600 mb-4 leading-relaxed">
                            使用 <code class="bg-gray-100 px-2 py-1 rounded">ethtool</code> 命令优化网卡性能，包括调整